<template>
	<view class="gui-flex gui-rows gui-wrap gui-space-between" v-if="products.length>0">
		<view class="gui-product" hover-class="gui-tap" v-for="(item, index) in products" :key="index"
			@tap="gotoInfo(index, item)" :style="{
			width  : (368 - margin*2)+'rpx',
			marginLeft  : margin+'rpx',
			marginRight : margin+'rpx'}">
			<view>
				<gui-image :src="item.image" :width="(368 - margin*2)" :height="imgHeight"></gui-image>
			</view>
			<view class="gui-product-lines gui-flex gui-columns gui-space-between">
				<text class="gui-product-name">{{item.title}}</text>
				<view class="gui-flex gui-rows gui-nowrap gui-align-items-center gui-space-between">
					<text class="gui-color-red gui-text">￥{{item.price}}</text>
					<!-- <text class="gui-text-small gui-color-gray gui-line-through gui-price-margin">{{item.ot_price}}</text> -->
					<text class="gui-text-small gui-color-gray gui-price-margin">{{item.sales}}人购买</text>
				</view>
			</view>
		</view>
	</view>
	<view v-else>
		<gui-empty>
			<view slot="img" class="gui-flex gui-rows gui-justify-content-center">
				<!-- 请根据您的项目要求制作并更换为空图片 -->
				<image class="gui-empty-img"
					src="https://upload-images.jianshu.io/upload_images/15372054-1f849183cebb80b1.png?imageMogr2/auto-orient/strip|imageView2/2/w/388/format/webp">
				</image>
			</view>
			<text slot="text" class="gui-text-small gui-block-text gui-text-center gui-margin-top"
				style="color:#9DABFF;">暂无数据 ......</text>
		</gui-empty>
	</view>
</template>
<script>
	export default {
		name: "gui-product-list",
		props: {
			products: {
				type: Array,
				default: function() {
					return [];
				}
			},
			margin: {
				type: Number,
				default: 15
			},
			imgHeight: {
				type: Number,
				default: 310
			},
		},
		methods: {
			gotoInfo: function(idx, item) {
				this.$emit('gotoInfo', idx, item);
				uni.navigateTo({
					url:"/pages/modules/activity/good_combination/index?product_id="+item.product_id+"&combination_id="+item.id
				})
			}
		}
	}
</script>
<style>
	.gui-product {
		margin-bottom: 38rpx;
		box-shadow: 2rpx 4rpx 12rpx 4rpx rgba(0, 0, 0, 0.1);
		border-radius: 16rpx;
		background-color: #fff;
	}

	.gui-product-lines {
		/* margin-top: 10rpx; */
		height: 150rpx;
		padding: 15rpx;
	}

	.gui-product-name {
		font-size: 24rpx ;
		text-overflow: ellipsis;
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		/* margin-bottom: 10rpx; */
	}
	
	.gui-price-margin {
		margin: 0 10rpx;
	}
</style>
